package com.zjl.zweather.ui.place

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import androidx.lifecycle.ViewModel
import com.zjl.zweather.logic.Repository
import com.zjl.zweather.logic.model.Place

/**
 * Created by admin on 2020/12/8 .
 * With com.zjl.zweather.ui.place
 */
/**
 * Created by admin on 2020/12/8 .
 * With com.zjl.zweather.ui.place
 */
class PlaceViewModel: ViewModel() {

    private val searchLiveData = MutableLiveData<String>()

    val placeList = ArrayList<Place>()

    val placeLiveData = Transformations.switchMap(searchLiveData){
        Repository.searchPlaces(it)
    }

    fun searchPlace(query: String){
        searchLiveData.value = query
    }



}